import React from 'react'
import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
import Index from './layout/index.jsx'
import Login from './views/login/Index.jsx'
import "./index.css"
import { connect } from 'react-redux'


const App = (props) => {
    return (
        <React.Fragment>
            <Router>
                <Switch>
                    {/* <Route path="/login" component={Login} />   
                    <Route path="/" component={Index} /> */}
                    <Route path="/login" component={Login} />
                    {
                        props.isLogin ?
                            <Route path="/" component={Index} />
                            : <Redirect to="/login" />
                    }
                </Switch>
            </Router>
        </React.Fragment>
    )
}

export default connect( state => {
    return {
        isLogin: state.getIn(['user', 'isLogin'])
    }
} )(App)